package org.opens.controller;

import org.opens.util.ClientUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述
 *
 * @author by zhangyuming
 * @date 2022/8/18
 */
@RestController
@RequestMapping(value = "/api")
public class WebserviceInvokeController {

    /**
     * 调用对应的webservice服务端接口
     * @param username 入参
     */
    @RequestMapping(value = "/catService")
    public String runCatService(String username) {
        String url = "http://localhost:30002/webService/CatService?wsdl";
        String methodName = "message";

        try {
            return ClientUtil.callWebSV(url, methodName, username);
        } catch (Exception e) {
            return "失败";
        }
    }

    /**
     * 调用webservice的另一个接口
     * @param username 入参
     */
    @RequestMapping(value = "/testService")
    public String runTestService(String username) {
        String url = "http://localhost:30002/webService/TestService?wsdl";
        String methodName = "sendMessage";

        try {
            return ClientUtil.callWebSV(url, methodName, username);
        } catch (Exception e) {
            return "失败";
        }
    }

}
